package com.itheima.dao;

import com.itheima.pojo.OrderSetting;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface OrderSettingDao_lzl {
    /*
    * 根据日期。查询是否存在预约数据
    * */
    @Select("select count(*) from t_ordersetting where orderDate=#{orderDate}")
    Integer findcountByorderDate(Date orderDate);


    /*
    * 根据日期进行更新预约数据
    * */
//    @Update("update t_ordersetting set number=#{number} where orderDate=#{orderDate}")
    @Update("<script> update t_ordersetting"+
                "<set>"+
                    "<if test='number!=null'> number=#{number},</if>"+
                    "<if test='reservations!=null'> reservations=#{reservations},</if>"+
                "</set>"+
                "where orderDate = #{orderDate}"+
            "</script>"
    )
    void updateByOrderDate(OrderSetting orderSetting);
    /*
    * 添加预约数据
    * */
    @Insert("insert into t_ordersetting values(#{id},#{orderDate},#{number},#{reservations})")
    void add(OrderSetting orderSetting);
    /*
    * 根据当月1号-31号的所有OrderSetting预约管理
    * */
    @Select("select * from t_ordersetting where orderDate between #{start} and #{end}")
    List<OrderSetting> getOrderSettingByMonth(Map map);

    @Select("select * from t_ordersetting where orderDate=#{orderDate}")
    OrderSetting findOrderSettingByOrderDate(Date orderDate);
}
